package com.ly.springboot.Controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Controller
public class HelloController {
    @GetMapping("/")
    @ResponseBody
    private  String hello(HttpServletRequest request){
        return "hello sb";
    }


    @GetMapping("/login")
    @ResponseBody
    private  String login(HttpServletRequest request){
        int i=1/0;
        request.getSession().setAttribute("LoginUser"," admin");
        return "登陆成功";
    }


    @GetMapping("/logout")
    @ResponseBody
    private  String logout(HttpServletRequest request){
        request.getSession().removeAttribute("LoginUser");
        return "登出成功";
    }


    @GetMapping("/index")
    private  String index(){
        return "index";
    }
}
